#include "gd_singleton.h"

#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/variant/utility_functions.hpp>

using namespace godot;

GdSingleton *GdSingleton::singleton = nullptr;

void GdSingleton::_bind_methods() {
	ClassDB::bind_method(D_METHOD("print"), &GdSingleton::print);
}

GdSingleton *GdSingleton::get_singleton() {
	return singleton;
}

GdSingleton::GdSingleton() {
	ERR_FAIL_COND(singleton != nullptr);
	singleton = this;
}

GdSingleton::~GdSingleton() {
	ERR_FAIL_COND(singleton != this);
	singleton = nullptr;
}

void GdSingleton::print() {
	UtilityFunctions::print("GD Singleton!");
}
